REM @echo off REM - This script searches through each home directory for temporary internet files and deletes them. REM - The script also empties the temp folder REM - THese lines set the starting directory for the script set HDRIVE=c: set HPATH=Users %HDRIVE% IISRESET.EXE /STOP REM - Clear all Windows Temp files if exist "%HDRIVE%\WINDOWS\Temp" call :WindowsTempDelete if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files" call :ASPNET11TempDelete if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" call :ASPNET20TempDelete if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files" call :ASPNET2064TempDelete cd \%HPATH% IISRESET.EXE /START REM - This line sets up the loop for the script for /d %%i in (*) do call :ifthen %%i goto end REM - These lines check for the presence of the temporary internet file directories and call subroutines to deal with them. :ifthen if exist "%HDRIVE%\%HPATH%\%1\AppData\Roaming\Microsoft\Terminal Server Client\Cache" call :TempMSTSCCache %1 if exist "%HDRIVE%\%HPATH%\%1\AppData\Local\Microsoft\Windows\Temporary Internet Files" call :ContentDelete1 %1 if exist "%HDRIVE%\%HPATH%\%1\AppData\Local\Temp" call :TempDelete %1 goto :EOF REM - This subroutine removes all folders located in the user's "Profile\Local Settings\Temporary Internet Files\Content.IE5" REM - directory (in their home directory). It then returns back to the line that it was called from. :WindowsTempDelete cd "%HDRIVE%\Windows\Temp" if exist "%HDRIVE%\Windows\Temp" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\Windows\Temp" del /q "%HDRIVE%\Windows\Temp\*" goto:EOF :ASPNET11TempDelete cd "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files" if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files" del /q "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\*" goto:EOF :ASPNET20TempDelete cd "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" del /q "%HDRIVE%\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\*" goto:EOF :ASPNET2064TempDelete cd "%HDRIVE%\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files" if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files" del /q "%HDRIVE%\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\*" goto:EOF :ContentDelete1 cd "%HDRIVE%\%HPATH%\%1\AppData\Local\Microsoft\Windows\Temporary Internet Files" if exist "%HDRIVE%\%HPATH%\%1\AppData\Local\Microsoft\Windows\Temporary Internet Files" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\%HPATH%\%1\AppData\Local\Microsoft\Windows\Temporary Internet Files" del /q "%HDRIVE%\%HPATH%\%1\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" goto :EOF REM - This subroutine removes all folders located in the user's "windows\Temporary Internet Files\Content.IE5" directory located REM - in their home directory. It then removes all subfolders from this directory. :TempDelete cd "%HDRIVE%\%HPATH%\%1\AppData\Local\Temp" if exist "%HDRIVE%\%HPATH%\%1\AppData\Local\Temp" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\%HPATH%\%1\AppData\Local\Temp" del /q "%HDRIVE%\%HPATH%\%1\Local\Temp\*" goto :EOF :TempMSTSCCache cd "%HDRIVE%\%HPATH%\%1\Roaming\Microsoft\Terminal Server Client\Cache" if exist "%HDRIVE%\%HPATH%\%1\Roaming\Microsoft\Terminal Server Client\Cache" for /d %%n in (*) do rd /s /q "%%n" if exist "%HDRIVE%\%HPATH%\%1\Roaming\Microsoft\Terminal Server Client\Cache" del /q "%HDRIVE%\%HPATH%\%1\Roaming\Microsoft\Terminal Server Client\Cache\*" goto :EOF :end